#!/usr/bin/env node

const http = require('https'),
  addr = process.argv[2],
  url = require('url');

let options = url.parse(global.encodeURI(addr));

//const addr = 'https://sample.wangding.co/web/one-div.html';

options.headers = {
  'User-Agent':'01-my-curl.js'
};

http.get(options, (res)=>{
  //res.pipe(process.stdout);
  console.log(` HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);
  console.log(res.headers);
  console.log();

  res.pipe(process.stdout);
});
//输出响应行、响应头、响应体




